package com.eight.travel.controller;

import com.eight.travel.pojo.StoreCom;
import com.eight.travel.service.StoreComService;
import com.eight.travel.utils.BaseResp;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
public class StoreComController {
    @Autowired
    StoreComService storeComService;

    //添加用户评价
    @ApiOperation(value = "添加用户对商场的评价",notes = "需传入 商场评论的信息")
    @PostMapping("/StoreCom/insertStoreCom")
    @ResponseBody
    public BaseResp addStoreCom(@RequestBody StoreCom storeCom){
        return storeComService.addStoreCom(storeCom);
    }

    //删除用户评价
    @ApiOperation(value = "删除用户对商场的评价",notes = "需传入 商场评论的信息的id")
    @PostMapping("/StoreCom/deleteStoreCom")
    public BaseResp deleteStoreCom(Integer scid){
        return  storeComService.deleteStoreCom(scid);
    }

    //修改用户评价(实时修改，并获取当前时间)
    @ApiOperation(value = "修改用户对商场的评价",notes = "需传入 商场评论的信息")
    @PostMapping("/StoreCom/updateStoreCom")
    @ResponseBody
    public BaseResp updateStoreCom(@RequestBody StoreCom storeCom){
        return storeComService.updateStoreCom(storeCom);
    }

    //查看所有评价（分页）
    @ApiOperation(value = "查看当前商场的所有评价",notes = "需传入 商场的id")
    @PostMapping("/StoreCom/findAll/{sid}")
    public BaseResp selectAll(@PathVariable Integer sid){
        return storeComService.selectAll(sid);
    }


}
